package com.gwsdk.paysdk.acitvityV2.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.gwsdk.paysdk.entity.MsgTZModel;
import com.gwsdk.paysdk.utils.GWInflaterUtils;

import java.util.ArrayList;
import java.util.List;

public class GWNoticeAdapter extends BaseAdapter {

    private Context context;
    private List<MsgTZModel.ListBean> listBeans = new ArrayList<>();
    public GWNoticeAdapter(Context context){
        this.context = context;
    }

    public void setListBeans(List<MsgTZModel.ListBean> listBeans) {
        this.listBeans = listBeans;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return listBeans.size();
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder viewHolder;
        if (view == null){
            viewHolder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(GWInflaterUtils.getLayout(context,"gw_item_notice"),null);
            viewHolder.titleView = view.findViewById(GWInflaterUtils.getControl(context,"title"));
            viewHolder.line = view.findViewById(GWInflaterUtils.getControl(context,"line"));
            view.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) view.getTag();
        }

        MsgTZModel.ListBean bean = listBeans.get(position);
        viewHolder.titleView.setText(bean.getTitle());

        return view;
    }

    private class ViewHolder{

        public View line;
        public TextView titleView;

    }
}
